﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using WBasicClassLib.IniByXml;

namespace IniByXmlWriter_Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            IniByXmlWriter Writer = new IniByXmlWriter("Test.xml", Encoding.UTF8);
            
            //1.输入几个XElement元素
            Writer.WriteInAElement(new XElement("T1", new XAttribute("attribute", "T1")));
            Writer.WriteInAElement(new XElement("T2", new XAttribute("attribute", "T2")), "This is Element 2!");
            Writer.WriteInAElement(new XElement("T3", new XText("Will Be Replaced")), "Have Been Replaced");
            
            //2.尝试输入重复名称的元素
            Writer.WriteInAElement(new XElement("T1"));
            Writer.WriteInAElement(new XElement("T2"));
            Writer.WriteInAElement(new XElement("T3"));
            
            Writer.Save();

            //3、添加新元素
            IniByXmlWriter newWriter = new IniByXmlWriter("Test.xml", Encoding.UTF8);
            newWriter.AddElement("T1", new XElement("T11"));
            newWriter.AddElement("T1", new XElement("T11"));
            newWriter.Save();
        }
    }
}
